/*
 PSPLang - this homebrew say you, which Language your PSP have.
 Copyright (C) 2011	Cha0z
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.
 
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 */

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspsdk.h>
#include <pspiofilemgr.h>
#include <pspctrl.h>
#include <pspthreadman_kernel.h>
#include <psppower.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <psputility_sysparam.h>

PSP_MODULE_INFO("psplang", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(0);

#define printf pspDebugScreenPrintf

int exit_callback(int arg1, int arg2, void *common)
{
	sceKernelExitGame();
	return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
	int cbid;

	cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
	sceKernelRegisterExitCallback(cbid);
	sceKernelSleepThreadCB();

	return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
	int thid = 0;

	thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
	if(thid >= 0)
	{
		sceKernelStartThread(thid, 0, 0);
	}

	return thid;
}


int main(void) {

pspDebugScreenInit();
SetupCallbacks();
int lang;	
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &lang);


if (lang == PSP_SYSTEMPARAM_LANGUAGE_GERMAN) {

printf("PSP Language: Deutsch\n");

}
else if (lang == PSP_SYSTEMPARAM_LANGUAGE_ENGLISH) {

printf("PSP Language: English\n");

}

else if (lang == PSP_SYSTEMPARAM_LANGUAGE_FRENCH) {

printf("PSP Language: France\n");

}

else if (lang == PSP_SYSTEMPARAM_LANGUAGE_ITALIAN) {

printf("PSP Language: Italiano\n");

}

else if (lang == PSP_SYSTEMPARAM_LANGUAGE_SPANISH) {

printf("PSP Language: Spanish\n");

}

sceKernelDelayThread(1200000);
sceKernelExitGame();

return 0;

}